#!/bin/bash

declare -r APP_NAME="${0##*/}"

print_usage() {
cat << EOF
Usage: $APP_NAME [OPTION]

Options:
  -h    Show this help message and exit
  -i    Increase volume
  -d    Decrease volume
  -m    Mute volume
EOF
}

if test $# == 0; then
    print_usage
fi

DBUS_SEND="dbus-send --type=method_call --dest=com.google.code.Volti /com/google/code/Volti com.google.code.Volti.emit"

while getopts ":hidm" opt; do
    case $opt in
        i) `${DBUS_SEND} string:'volume-up'`;;
        d) `${DBUS_SEND} string:'volume-down'`;;
        m) `${DBUS_SEND} string:'mute'`;;
        h) print_usage;;
        *) print_usage;;
    esac
done
